package com.dong.es.entity.dtocast.base;

import com.dong.es.entity.EsBaseDTO;
import com.dong.es.entity.EsViewDTO;
import com.dong.es.entity.dtocast.DTOCastMethod;
import com.dong.es.entity.searchparam.query.script.EsScriptQueryParam;

/**
 * @description:
 * @author: 陈瑞东
 * @create: 2022-11-28 19:54
 */
public class DTOCastScript extends DTOCastMethod {

    private String inline;
    private String lang;

    @Override
    protected Integer sizeLimit() {
        return 2;
    }

    @Override
    protected Class[] typeLimit() {
        return new Class[] {String.class, String.class};
    }

    @Override
    protected void load(Object... args) {
        String inline = args[0].toString();
        String lang = args[1].toString();

        this.inline = inline;
        this.lang = lang;
    }

    @Override
    protected void doCast(EsViewDTO viewDTO, EsBaseDTO baseDTO) {
        new EsScriptQueryParam(inline, lang).addTo(baseDTO);
    }
}

